package com.woniuxy01;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author 作者
 * @create 2025-06-09 10:35
 */
public class Test07 {
    public static void main(String[] args) {
        Map<String, Student> map = new HashMap<>();
        map.put("1", new Student("1", "zs", 11));
        map.put("2", new Student("2", "ww", 12));
        map.put("3", new Student("3", "ls", 13));
        //map遍历方法二：获取所有key-value的集合
        Set<Map.Entry<String, Student>> entries = map.entrySet();
        for(Map.Entry<String, Student> entry : entries){
            System.out.println(entry.getKey());
            System.out.println(entry.getValue());
        }
    }

    private static void testo2() {
        Map<String, Student> map = new HashMap<>();
        map.put("1", new Student("1", "zs", 11));
        map.put("2", new Student("2", "ww", 12));
        map.put("3", new Student("3", "ls", 13));
        //map遍历方法二：获取所有value的集合
        Collection<Student> values = map.values();
        for (Student student : values) {
            System.out.println(student);
        }
    }

    private static void test01() {
        Map<String, Student> map = new HashMap<>();
        map.put("1", new Student("1", "zs", 11));
        map.put("2", new Student("2", "ww", 12));
        map.put("3", new Student("3", "ls", 13));
        //map遍历方法一：获取所有key的集合
        Set<String> keys = map.keySet();
        for(String key : keys){
            System.out.println(key);
            System.out.println(map.get(key));
        }
    }
}
